import { defineStore } from "pinia"
import { ref } from "vue"
import { getCozeMessage } from "@/api/getCozeData"
import type { AiInfoType, AITranslateType } from "@/types/aiDataType"

export const useAiStore = defineStore('aipage', () => {
    const active = ref<number>(0)
    const input = ref<string>(" ")
    const aiTranslateState = ref<AITranslateType[]>([
        {
            role: 'assistant',
            type: 'answer', 
            content: `“to everything there is a season and a time to every purpose underheaven.
                    I hope you still take the time to run through the rain.”——
                    “世上万物皆有季节，万事皆有时机。我希望你仍会抽出时间在雨中奔跑。”`, 
            content_type: 'text'
        }
    ])
    const aiTuToringState = ref<AITranslateType[]>([
        {
            role: 'assistant',
            type: 'answer', 
            content: `你好，我是一名专业的外语学习助手，
            可以为您提供精准的翻译服务和全面的外语学习指导。
            无论您是需要翻译文本还是寻求外语学习建议，
            我都会尽力帮助您实现目标。`, 
            content_type: 'text'
        }
    ])
    const aiTypeState = ref<AiInfoType[]>([
        {
            id: 1,
            type: "AI翻译",
            placeholder: "请输入要翻译的文本"
        },
        {
            id: 2,
            type: "学习指导",
            placeholder: "请输入你的需求"
        }
    ])
    
    async function addMessage(input: string,id: number){
       return await getCozeMessage(input, id)
    }
    return {
        active,
        input,
        aiTranslateState,
        aiTuToringState,
        aiTypeState,
        addMessage,
    }
})